package org.example.chapter5.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.chapter5.entity.Blog;

import java.util.List;

@Mapper
public interface BlogMapper {
    //查询数据库里面所有博客信息
    @Select("select * from m_blog order by created_at desc ")
    List<Blog> selectAll();
    //通过offset和limit查询部分博客数据,跳过前面的 offset行，查询接下来的limit行
    @Select("select * from m_blog order by created_at desc limit #{limit} offset #{offset}")
    List<Blog> selectBlogsByPage(Integer offset, Integer limit);
    //查询数据库中有多少条数据
    @Select("select count(*) from m_blog")
    Integer selectCount();
}